from flask import Flask
from flask_admin import Admin, AdminIndexView
from flask_babelex import Babel
app = Flask(__name__, template_folder='templates')
app.config.from_object('config')
admin = Admin(app, name='后台管理系统', index_view=AdminIndexView(name='首页',template='admin/admin_index.html',url='/admin'), template_mode= 'bootstrap3')
from app import views, Models
from flask_sqlalchemy import SQLAlchemy
import os.path as op
# from celery import Celery
#
# app.config['CELERY_BROKER_URL'] = 'redis://localhost:6379/0'
# app.config['CELERY_RESULT_BACKEND'] = 'redis://localhost:6379/0'
# celery = Celery(app, broker=app.config['CELERY_BROKER_URL'])
# celery.conf.update(app.config)
# @celery.task
# def long_time_def(arg1, arg2):
#     print("准备")
#     print(arg1,arg2)
#     print("完成")
#     return 'hello'
from flask_admin.contrib.fileadmin import FileAdmin
db = SQLAlchemy(app)
babel = Babel(app)
app.config['BABEL_DEFAULT_LOCALE'] = 'zh_CN'
admin.add_view(views.MyView(name='用户',category='会员管理'))
admin.add_view(views.MyGroup(name='组',category='会员管理'))
admin.add_view(views.MyImage(name='图片管理', category='图片管理'))
admin.add_view(views.Workexib(name='原创', category='作品展示'))
admin.add_view(views.Cover(name='翻唱', category='作品展示'))
admin.add_view(views.Script_ben(name='脚本'))
# admin.add_view(views.MyAdmin_user(Models.User_users, db.session,category='会员管理',name='用户1'))
# admin.add_view(views.MyAdmin_groups(Models.User_groups, db.session,category='会员管理',name='组1'))
path = op.join(op.dirname(__file__), 'static')
admin.add_view(FileAdmin(path, '/static/', category='图片管理', name='首页图片1', url='filename/'))
# admin.add_view(admin_view.MyAdmin_groups(Models.User_groups, db.session,category='会员管理',name='z'))

